#ifndef _CHANNEL_H_
#define _CHANNEL_H_

#include "../Common/cTypes.h"
#include <string>

using namespace std;

#ifdef _SCALE_MSK_
#include "../Lib/scale_msk.h"
#endif

// 4 channels and interface
#define CW 320
#define CH 240

#define CX (CW*2)
#define CY (CH*2)

#define CWX (CW*9/4)
#define CWY (CH*2)

class CChannel
{
public:                            
	CChannel();
	~CChannel();

	BYTE *YBuffer;
	BYTE *UVBuffer;

	BYTE YBufferS[CWX*CWY];
	BYTE UVBufferS[CWX*CWY];




    BYTE *OffY1, *OffY2, *OffY3, *OffY4; // for 320x240 and 640x480 and 160x120 , 720x480
	BYTE *OffUV1, *OffUV2, *OffUV3, *OffUV4; // for 320x240 and 640x480 and 160x120 , 720x480
           BYTE *pTmp;
           string OffName;
           int FrameSize; // one of FS_320x240, FS_640x480, FS_160x120

	BYTE* pY[8];
	BYTE* pU[8];
	BYTE* pV[8];

#ifdef VC10
    int width;
    int height;
#endif

#ifdef _SCALE_MSK_
	ScaleFilterData m_sfd;
	bool scaleinit;
#endif
	int m_nActiveChannel;
	void ClearChannels();
	void SetActiveChannel(int nChannel);
	void LoadFrameFromCamera(int, DWORD);
           void LoadFrameFromBMP(string filename);
           void SetFrameSize(int NewFrameSize); // one of FS_FULLSCREEN, FS_320x240, FS_640x480, FS_160x120 // important of offline image

private:
	void Line(int x0, int y0, int x1, int y1);
           void Size2up(BYTE* p0, BYTE* p1, int w0, int h0);
           void Size2dn(BYTE* p0, BYTE* p1, int w0, int h0);

};

#endif